package deleteStrategy

import (
	"log"

	"github.com/zhuxiujia/GoMybatis"
)

// UpdateTimePrioity 更新时间优先
type UpdateTimePrioity struct {
	MaxExpirTime int
}

func (updateTimePrioity UpdateTimePrioity) Delete(session GoMybatis.Session) (int64, error) {
	result, err := session.ExecPrepare("delete from monitor where update_time-(select date('now'))>=?", updateTimePrioity.MaxExpirTime)
	defer func() {
		session.Commit()
	}()
	if err != nil {
		log.Println(err)
		session.Rollback()
	}
	return result.RowsAffected, err
}
